#include<bits/stdc++.h>
using namespace std;
#define ll long long

int solve(double m, vector<int> vn) {
  int index = 0;
  int mindiff = abs(vn[0] - m);
  for (int i = 0; i < vn.size(); i++) {
    int diff = abs(vn[i] - m);
    if (diff <= mindiff) {
      mindiff = diff;
      index = vn[i];
    }
  }
  return index;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vn(n);
  for (int i = 0; i < n; ++i) {
    cin >> vn[i];
  }
  vector<double> vm(m);
  for (int i = 0; i < m; ++i) {
    cin >> vm[i];
  }
  for (int i = 0; i < m; ++i) {
    int res = solve(vm[i], vn);
    cout << res << endl;
  }

  return 0;
}